package com.fortune.cat.resolver;

import com.fortune.cat.enums.RateLimiterKeyResolverEnums;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;

/**
 * @author zhaozeyang
 * @date 2019/4/26 11:22
 * @description
 */
@Component
public class ClientIpKeyResolver extends AbstractKeyResolver {


    @Override
    public Integer getType() {
        return RateLimiterKeyResolverEnums.CLIENT_IP.getType();
    }

    @Override
    protected String doResolve(ServerWebExchange exchange) {
        return exchange.getRequest().getHeaders().getFirst("X-Real-IP");
    }

}
